x86-64: don't crash Xen upon direct pv guest access to GDT/LDT mapping area
authorKeir Fraser <keir@xen.org>
Mon, 29 Nov 2010 14:34:32 +0000 (14:34 +0000)
committerKeir Fraser <keir@xen.org>
Mon, 29 Nov 2010 14:34:32 +0000 (14:34 +0000)
commitd4d2cb21138e5ac6c24e62ff7440d2846dc43a16
tree6f903525f5e163f76d6a5df4093d6c625f74d9a8
parent375547eb7607a65674756356337418793b13ab0c
x86-64: don't crash Xen upon direct pv guest access to GDT/LDT mapping area

handle_gdt_ldt_mapping_fault() is intended to deal with indirect
accesses (i.e. those caused by descriptor loads) to the GDT/LDT
mapping area only. While for 32-bit segment limits indeed prevent the
function being entered for direct accesses (i.e. a #GP fault will be
raised even before the address translation gets done, on 64-bit even
user mode accesses would lead to control reaching the BUG_ON() at the
beginning of that function.

Fortunately the fix is simple: Since the guest kernel runs in ring 3,
any guest direct access will have the "user mode" bit set, whereas
descriptor loads always do the translations to access the actual
descriptors as kernel mode ones.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Further, relax the BUG_ON() in handle_gdt_ldt_mapping_fault() to a
check-and-bail. This avoids any problems in future, if we don't
execute x86_64 guest kernels in ring 3 (e.g., because we use a
lightweight HVM container).

Signed-off-by: Keir Fraser <keir@xen.org>
xen/arch/x86/traps.c